package com.fansl.allround.common.core.constant;

/**
 * @author fansl
 * @Description: 安全服务相关常量
 * @date 2019/7/11 15:29
 */
public interface SecurityConstants {
    /**
     * 项目前缀
     */
    String PROJECT_PREFIX = "allround_";

    /**
     * oauth 相关前缀
     */
    String OAUTH_PREFIX = "oauth:";

    /**
     * 项目的licens
     */
    Object PROJECT_LICENSE = "made in china";
    /**
     * 默认登录URL
     */
    String OAUTH_TOKEN_URL = "/oauth/token";
    /**
     * 手机号登录URL
     */
    String MOBILE_TOKEN_URL = "/mobile/token";
    /**
     * 系统用户第三方登录URL
     */
    String SOCIAL_TOKEN_URL = "/social/token";
    /**
     * 用户中心第三方登录URL
     */
    String UCENTER_SOCIAL_TOKEN_URL = "/ucenter/social/token";
    /**
     * grant_type
     */
    String REFRESH_TOKEN = "refresh_token";
    /**
     * from标志
     */
    String FROM = "from";
    /**
     * 内部
     */
    String FROM_IN = "Y";

    /**
     * 资源服务器默认bean名称
     */
    String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";

    /**
     * 角色前缀
     */
    String ROLE = "ROLE_";

    /**
     * oauth 客户端信息
     */
    String CLIENT_DETAILS_KEY = PROJECT_PREFIX + OAUTH_PREFIX + "client:details";

    /**
     * {bcrypt} 加密的特征码
     */
    String BCRYPT = "{bcrypt}";

    /**
     * sys_oauth_client_details 表的字段，不包括client_id、client_secret
     */
    String CLIENT_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, "
            + "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
            + "refresh_token_validity, additional_information, autoapprove";

    /**
     * JdbcClientDetailsService 查询语句
     */
    String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS
            + " from sys_oauth_client_details";

    /**
     * 默认的查询语句
     */
    String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id";

    /**
     * 按条件client_id 查询
     */
    String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ?";

    /**
     * 服务名字段
     */
    String DETAILS_SERVICE_NAME = "service_name";
    /**
     * 用户ID字段
     */
    String DETAILS_USER_ID = "user_id";

    /**
     * 用户名字段
     */
    String DETAILS_USERNAME = "username";

    /**
     * 用户部门字段
     */
    String DETAILS_DEPT_ID = "dept_id";

    /**
     * 协议字段
     */
    String DETAILS_LICENSE = "license";
    /**
     * 客户端ID
     */
    String CLIENT_ID = "client_id";
    /**
     * outh2客户端的授权模式
     */
    String[] AUTHORIZED_GRANT_TYPES = {"password","refresh_token","authorization_code","client_credentials","refresh_token"};

    /**
     * 密码模式
     */
    String AUTHORIZED_GRANT_TYPE_PASSWORD = "password";
    /**
     * 简化模式
     */
    String AUTHORIZED_GRANT_TYPE_IMPLICIT = "implicit";

    /**
     * 授权码模式
     */
    String AUTHORIZED_GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code";

    /**
     * 客户端模式
     */
    String AUTHORIZED_GRANT_TYPE_CLIENT_CREDENTIALS = "client_credentials";

    /**
     * 通过以上授权获得的刷新令牌来获取新的令牌
     */
    String AUTHORIZED_GRANT_TYPE_REFRESH_TOKEN = "refresh_token";

    /**
     * 手机号码登录发送验证码redisKey
     * 格式：login:sms:服务名:手机号码
     */
    String LOGIN_SMS_CODE_KEY = "login:sms:%s:%s";
    /**
     * 手机号码登录发送验证码次数redisKey
     * 格式：login:sms:send:服务名:手机号码
     */
    String LOGIN_SEND_SMS_CODE_TIMES_KEY = "login:sms:send:%s:%s";
    /**
     * 手机号码登录发送验证码时间间隔redisKey
     * 格式：login:sms:send:interval:服务名:手机号码
     */
    String LOGIN_SEND_SMS_CODE_TIMES_INTERVAL_KEY = "login:sms:send:interval:%s:%s";
    /**
     * 社交登录获取的信息redisKey（社交账号的openId,accessToken）
     * 格式：social:login:openid:服务名:社交类型:社交账号返回的code
     */
    String SOCIAL_LOGIN_OPENID_KEY = "social:login:openid:%s:%s:%s";
    /**
     * 登录绑定手机号发送验证码redisKey
     * 格式：login:bind:sms:服务名:手机号码
     */
    String LOGIN_BIND_SMS_CODE_KEY = "login:bind:sms:%s:%s";
    /**
     * 登录发送验证码时间间隔redisKey
     * 格式：login:bind:sms:send:interval:服务名:手机号码
     */
    String LOGIN_SEND_BIND_SMS_CODE_TIMES_INTERVAL_KEY = "login:bind:sms:send:interval:%s:%s";
}
